
function customerFeedback() {
    $.ajax({
        url:root.sroreinter.searchAfterFreeBackList,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        contentType: "application/json",
        data: JSON.stringify({
            "pageNum":1,
            "pageSize":30,
            "questionType":$("#questionType").val(),
            "status":$("#status").val(),
            "wordsDetail":$("#wordsDetail").val(),
            "feedbackId":$("#feedbackId").val(),
            "accountType":$("#accountType").val(),
            "mobilePhone":$("#mobilePhone").val(),
            "startTime":$("#startTime").val(),
            "endTime":$("#endTime").val(),
            "loginAccount":$("#loginAccount").val()


        }),
        success: function (data) {
            sessionStorage.setItem("customerFeedbackstatus",'')
            customerFeedbacklist(data.data, 0);
            $('.M-box3').pagination({
                pageCount: data.data.pageCount,
                jump: true,
                coping: true,
                prevContent: '上页',
                nextContent: '下页',
                callback: function (api) {
                    $.ajax({
                        url: root.sroreinter.searchAfterFreeBackList,
                        cache: false,  //禁用缓存
                        type: "POST",
                        dataType:'json',
                        contentType: "application/json",
                        data: JSON.stringify({
                            "pageNum":api.getCurrent(),
                            "pageSize":30,
                            "questionType":$("#questionType").val(),
                            "status":$("#status").val(),
                            "wordsDetail":$("#wordsDetail").val(),
                            "feedbackId":$("#feedbackId").val(),
                            "accountType":$("#accountType").val(),
                            "mobilePhone":$("#mobilePhone").val(),
                            "startTime":$("#startTime").val(),
                            "endTime":$("#endTime").val(),
                            "loginAccount":$("#loginAccount").val()
                        }),
                        success: function (result) {
                            customerFeedbacklist(result.data);
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest);
                        }
                    });
                }
            });

        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    });
}
var dataSource2 = new Array();
var table2;   //table对象
dataSource2 = [];
function customerFeedbacklist(data, index){
    dataSource2.splice(0,dataSource2.length);//清空数组
    if(data.data !=null && data.data != ''){
        var datashu =data.startRow+1;
        $.each(data.data, function (i, field) {
            var datashus = datashu++
            var rowData = new Array();
            rowData.push(datashus);
            rowData.push(field.feedbackId);
            rowData.push(field.accountType);
            rowData.push(field.loginAccount);
            rowData.push(field.userName);
            rowData.push(field.mobilePhone);
            rowData.push(field.questionType);
            rowData.push(field.status);
            rowData.push(field.replyTime);
            rowData.push(field.id);
            dataSource2.push(rowData);

        });
    }
    initDataTable(dataSource2);
    function initDataTable(dataSource2) {

        var dttable = $('#customerFeedbacktable').dataTable(); // 初始化dataTable，清空上一个值
        dttable.fnClearTable(); //清空一下table
        dttable.fnDestroy(); //还原初始化了的datatable
        $("#customerFeedbacktable").DataTable({
            // "order": false,
            "autoWidth": false,
            "ordering": false,
            "searching": false,
            "paging": false,
            "retrieve": true,
            "destroy": true,
            "bAutoWidth": true,
            "bLengthChange": true,
            "aLengthMenu": false,
            "oLanguage": {
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "抱歉， 没有找到",
                "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                "sInfoEmpty": "没有数据",
                "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "前一页",
                    "sNext": "后一页",
                    "sLast": "尾页"
                },
                "sZeroRecords": "没有检索到数据",
            },
            data: dataSource2,
            columnDefs: [
                {
                    "visible": true,
                    "targets": 0
                },
                {
                    "render": function (data, type, row, meta) {
                        var val = row[0]
                        if (val == undefined) {
                            val = ''
                        }
                        return val;
                    },
                    "targets": 0
                },

                {
                    "render": function (data, type, row, meta) {
                        var val = row[1]
                        if (val == undefined) {
                            val = ''
                        }
                        return val;
                    },
                    "targets": 1
                },

                {
                    "render": function (data, type, row, meta) {
                        var val = ""
                        if (row[2] == 10) {
                            val = '分销客户'
                        }else if (row[2] == 20) {
                            val = '普通会员'
                        }
                        else if (row[2] == 30) {
                            val = '认证会员'
                        }
                        else if (row[2] == 40) {
                            val = '签约非分销'
                        }
                        return val;
                    },
                    "targets": 2
                },
                {
                    "render": function (data, type, row, meta) {
                        var val = row[3]
                        if (val == undefined) {
                            val = ''
                        }
                        return val;
                    },
                    "targets":3
                },
                {
                    "render": function (data, type, row, meta) {
                        var val = row[4]
                        if (val == undefined) {
                            val = ''
                        }
                        return val;
                    },
                    "targets": 4
                },

                {
                    "render": function (data, type, row, meta) {
                        var val = row[5]
                        if (val == undefined) {
                            val = ''
                        }
                        return val;
                    },
                    "targets": 5
                },
                {
                    "render": function (data, type, row, meta) {
                        var val = ""
                        if (row[6] == 10) {
                            val = '功能问题'
                        }else  if (row[6] == 20){
                            val = '商品问题'
                        }else  if (row[6] == 30){
                            val = '物流问题'
                        }else  if (row[6] == 40){
                            val = '服务问题'
                        }else  if (row[6] == 50){
                            val = '其他问题'
                        }
                        return val;
                    },
                    "targets": 6
                },
                {
                    "render": function (data, type, row, meta) {
                        var val = ""
                        if (row[7] == 10) {
                            val = '已接收'
                        }else {
                            val = '已回复'
                        }
                        return val;
                    },
                    "targets": 7
                },
                {
                    "render": function (data, type, row, meta) {
                        var val = row[8]
                        if (val =="1000-01-01 00:00:00") {
                            val = ''
                        }else {
                            val =row[8]
                        }
                        return val;
                    },
                    "targets": 8
                },

                {
                    "render": function (data, type, row, meta) {
                        var val ='<span class=" powerButton 568" ><a onclick="viewDetails(\'意见反馈详情\',\'customerFeedback_details.html\',\''+row[9]+'\')">查看详情</a></span>'
                        return val;
                    },
                    "targets": 9
                },


            ]
        });
        //权限控制函数
        power()
    };
}
//查看详情
function viewDetails(title,url,id) {
    sessionStorage.setItem("id",id)
    var index = layer.open({
        type: 2,
        title: title,
        content: url
    });
    layer.full(index);
}
//弹框跳转
var customerFeedbackstatus= sessionStorage.getItem("customerFeedbackstatus")
if(customerFeedbackstatus==10){
    $('#status').val(customerFeedbackstatus)
    customerFeedback()
}